use std::env;

use ane_cms::dao::{ArticleDetailVo, ArticleListVo};
use sea_orm::{Database, DbConn};

async fn get_db() -> DbConn {
    dotenv::dotenv().ok();
    let databaseurl = env::var("DATABASEURL").unwrap();
    Database::connect(databaseurl).await.unwrap()
}

#[tokio::main]
#[test]
async fn test_init_db() {
    let db = get_db().await;
    ane_cms::mutation::init_db(&db).await.unwrap();
}

#[tokio::main]
#[test]
async fn test() {
    let db = get_db().await;
    let s = ane_cms::dao::Manager::list_article::<ArticleListVo>(&db, 0, 12, 1, None,None)
        .await
        .unwrap();
    println!("{s:?}");
}
